﻿using Appliaction.Dto.FG;
using Appliaction.IAppServices.FG;
using AutoMapper;
using Domain.Entitys.FG;
using Domain.Entitys.Inv;
using Domain.IRepositorys.FG;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Appliaction.AppServices.FG
{
    public class FG_Picking_OutboundService : IFG_Picking_OutboundService
    {
        private readonly IMapper mapper;
        private readonly IFG_Picking_OutboundRepository fG_Picking_OutboundRepository;

        public FG_Picking_OutboundService(IMapper mapper,IFG_Picking_OutboundRepository fG_Picking_OutboundRepository)
        {
            this.mapper = mapper;
            this.fG_Picking_OutboundRepository = fG_Picking_OutboundRepository;
        }
        public int GetFG_Picking_OutboundCount(string Picking_outbound_code, string Warehouse_code)
        {
            return fG_Picking_OutboundRepository.GetFG_Picking_OutboundCount(Picking_outbound_code, Warehouse_code);
        }

        public List<FG_Picking_Outbound_Info> GetFG_Picking_OutboundFYwhere(string Picking_outbound_code, string Warehouse_code, int currentPage, int pageSize)
        {
            return fG_Picking_OutboundRepository.GetFG_Picking_OutboundFYwhere(Picking_outbound_code, Warehouse_code, currentPage, pageSize);
        }

        public Task<List<inv_stock>> GetInv_StockAsyncs(string Warehouse_Code, string Zone_Code, string pro_code, int pro_attribute_id, int currentPage, int pageSize)
        {
            return fG_Picking_OutboundRepository.GetInv_StockAsyncs(Warehouse_Code, Zone_Code, pro_code, pro_attribute_id, currentPage, pageSize);
        }

        public Task<int> Inv_StockCountAsyncs(string Warehouse_Code, string Zone_Code, string pro_code, int pro_attribute_id)
        {
            return fG_Picking_OutboundRepository.Inv_StockCountAsyncs(Warehouse_Code, Zone_Code, pro_code, pro_attribute_id);
        }

        public Task<int> PutFG_Picking_OutboundAdd(Fg_Picking_Outbound_OrderAddDto<FG_Picking_Outbound_AddDto> fg_Picking_Outbound_OrderAdd)
        {
            FG_Picking_Outbound fG_Picking_Outbound = mapper.Map<FG_Picking_Outbound>(fg_Picking_Outbound_OrderAdd.Fg_Picking_Outbound_InfoAddDto);
            List<Fg_Picking_Outbound_Details> fg_Picking_Outbound_Details = mapper.Map<List<Fg_Picking_Outbound_Details>>(fg_Picking_Outbound_OrderAdd.Fg_Picking_Outbound_DetailsAddDtos);
            return fG_Picking_OutboundRepository.PutFG_Picking_OutboundAdd(fG_Picking_Outbound, fg_Picking_Outbound_Details);
        }

        public Task<int> PutFg_Picking_OutboundAudit(Fg_Picking_Outbound_OrderAuditDto<FG_Picking_Outbound_AuditDto> fg_Picking_Outbound_OrderAuditDto)
        {
            FG_Picking_Outbound fG_Picking_Outbound = mapper.Map<FG_Picking_Outbound>(fg_Picking_Outbound_OrderAuditDto.FG_Picking_Outbound_AuditDto);
            List<Fg_Picking_Outbound_Details> fg_Picking_Outbound_Details = mapper.Map<List<Fg_Picking_Outbound_Details>>(fg_Picking_Outbound_OrderAuditDto.fg_Picking_Outbound_DetailsAuditDtos);
            return fG_Picking_OutboundRepository.PutFg_Picking_OutboundAudit(fG_Picking_Outbound, fg_Picking_Outbound_Details);
        }

        public Task<int> PutFG_Picking_OutboundDelete(FG_Picking_Outbound_DeleteDto fG_Picking_Outbound_DeleteDto)
        {
            FG_Picking_Outbound fg = mapper.Map<FG_Picking_Outbound>(fG_Picking_Outbound_DeleteDto);
            return fG_Picking_OutboundRepository.PutFG_Picking_OutboundDelete(fg);
        }

        public Task<int> PutFg_Picking_OutboundUpdate(Fg_Picking_Outbound_OrderUpdateDto<FG_Picking_Outbound_UpdateDto> fg_Picking_Outbound_OrderUpdateDto)
        {
            FG_Picking_Outbound fG_Picking_Outbound = mapper.Map<FG_Picking_Outbound>(fg_Picking_Outbound_OrderUpdateDto.FG_Picking_Outbound_UpdateDto);
            List<Fg_Picking_Outbound_Details> fg_Picking_Outbound_Details = mapper.Map<List<Fg_Picking_Outbound_Details>>(fg_Picking_Outbound_OrderUpdateDto.fg_Picking_Outbound_DetailsUpdateDtos);
            return fG_Picking_OutboundRepository.PutFg_Picking_OutboundUpdate(fG_Picking_Outbound, fg_Picking_Outbound_Details);
        }
    }
}
